//# sourceURL=companyList.js
layui.element.on('tab(login-user-tabs)', function () {
    var currPage = 1;
    var companyList_fn = {
        initRender: function () {
            layui.table.render({
                id: 'companyListTableId',
                elem: '#companyList-table',
                url: '/inviteCompany/list',
                height: 'full-170',
                page: true,
                limits: cmsUtils.getLimits(),
                limit: cmsUtils.getLimit(),
                cols:[[
                    {title: '<b>序号</b>',type: 'numbers',align: 'center',width: 80},
                    {title: '<b>公司名称</b>',field: 'companyName',width: 180},
                    {title: '<b>行业</b>',field: 'industry',width: 180},
                    {title: '<b>融资情况</b>',field: 'financingValue',width: 180},
                    {title: '<b>地址</b>',field: 'address'},
                    {title: '<b>规模</b>',field: 'scaleValue'},
                    {title: '<b>创建时间</b>',field: 'createDate',align: 'center',width: 160},
                    {title: '<b>操作选项</b>',width: 160,align: 'center',toolbar: '#companyList-toolbar'}
                ]],
                done: function (res, curr, count) {
                    currPage = curr;
                    $('#companyList').attr('hasRender', true);
                }
            });
        },
        reload: function (page) {
            layui.table.reload('companyListTableId', {
                page:{
                    curr: page ? page : currPage
                },
                where:{
                    companyName: $('#companyList-input-companyName').val()
                }
            });
        },
        refreshList: function () {
            if ($('#companyList')[0]) {
                companyList_fn.reload(currPage);
            }
        },
        resetSearch: function () {
            $('#companyList-input-companyName').val('');
            companyList_fn.reload(1);
        }
    }
    if (!$('#companyList').attr('hasRender')) {
        companyList_fn.initRender();
        // 监听当前Tab页点击
        $(this).bind('tabClick', function () {
            companyList_fn.refreshList();
        });
        // 搜索
        $('#companyList-search-btn').click(function () {
            companyList_fn.reload(1);
        });
        // 重置
        $('#companyList-refresh-btn').click(function () {
            companyList_fn.resetSearch();
        });
        // 新增
        $('#companyList-add-btn').click(function () {
            cmsUtils.addContentTab('companyDetail', '帐号-添加', '/piger/platform/userManage/companyDetail.html', {
                list_fn: companyList_fn
            });
        });
    }
    // 工具条监听
    layui.table.on('tool(companyList-table)', function (obj) {
        switch (obj.event) {
            case 'edit':
                cmsUtils.addContentTab('companyDetail', '帐号-编辑', '/piger/platform/userManage/companyDetail.html', {
                    id: obj.data.id,
                    list_fn: companyList_fn
                });
                break;
            default:
                break;
        }
    });
});